<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function func(num) {
      return function () {
        // #1
        console.log(num)
      };
    }
    setTimeout(func(1));

    async function async3() {
      // 这里执行 async4() 确实打印了 5，但同时产生了一个微任务
      await async4();
      // #2
      console.log(8);
    }
    async function async4() {
      console.log(5)
    }
    async3();
    function func2() {
      // #3
      console.log(2);
      async function async1() {
        // 这里执行 async2()直接打印5，但同时产生一个微任务 #6
        await async2();
        console.log(9) // #6
      }
      async function async2() {
        console.log(5)
      }
      async1();
      setTimeout(func(4))
    }
    setTimeout(func2);

    setTimeout(func(3));

    new Promise(resolve => {
      console.log('Promise');
      resolve()
    })
      .then(() => console.log(6)) // #4，这里确实打印了6，但同时产生了一个微任务
      .then(() => console.log(7)); // #5
    console.log(0);
  </script>
</body>

</html>